//
//  FourthViewController.m
//  XDCommonApp
//
//  Created by XD-XY on 2/12/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "FourthViewController.h"
#import "XDHeader.h"
#import "UMSocial.h"
#import "LoginViewController.h"
#import "PersonSetViewController.h"
#import "WaterFLayout.h"
#import "WaterF.h"
#import "WaterFlow.h"
#import "DetailforArtistVC.h"
#import "XDTools.h"
#import "ArtistCell.h"
#import "ArtistItem.h"
#import "UIImageView+WebCache.h"
#define KPICHEIGHT 150
@interface FourthViewController ()

@end

@implementation FourthViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [[NSUserDefaults standardUserDefaults] setObject:@"yes" forKey:@"SecondViewHiddenSearch"];
    
    uid = [[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_ID];
    d1Count = @"0";
    d2Count = @"0";
    page = 0;
    isHeaderRefresh = YES;
    isHaveMoreData = YES;
    danwei = @"件作品";
    
    [self myInfoIsArtist];
    dataArrary = [NSMutableArray arrayWithCapacity:3];
	// Do any additional setup after loading the view.
    UIButton *lauBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [lauBtn setTitle:@"登录" forState:UIControlStateNormal];
    lauBtn.frame = self.leftBtn.frame;
    
    [lauBtn addTarget:self action:@selector(goLaun) forControlEvents:UIControlEventTouchUpInside];
//    [self.navigationBarView addSubview:lauBtn];
    [self.leftBtn removeFromSuperview];
    
    self.titleLabel.text = FOURTHVIEWTITLETEXT;
    self.titleLabel.textColor = [UIColor blackColor];
    self.titleLabel.font = [UIFont systemFontOfSize:20];
    UIButton *rBtn = [UIButton buttonWithType:UIButtonTypeCustom];
   
    rBtn.frame = CGRectMake(276,0,44,44);
    [rBtn addTarget:self action:@selector(goToSetting) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *rightView = [[UIImageView alloc] initWithFrame:CGRectMake(rBtn.frame.origin.x+13, 13, 18, 18)];
    
    yesView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
    
    button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(0, 0, 213/2, 40);
    [button1 setBackgroundImage:[UIImage imageNamed:@"art_collection"] forState:UIControlStateNormal];
    [button1 setBackgroundImage:[UIImage imageNamed:@"art_collection_down"] forState:UIControlStateSelected];
    button1.tag = 101;
    [button1 addTarget:self action:@selector(button1FirstAction:) forControlEvents:UIControlEventTouchUpInside];
    button1.selected = YES;
    
    [yesView addSubview:button1];
    
    button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(213/2, 0, 107, 40);
    [button2 setBackgroundImage:[UIImage imageNamed:@"attend_artist_160"] forState:UIControlStateNormal];
    [button2 setBackgroundImage:[UIImage imageNamed:@"attend_artist_160_down"] forState:UIControlStateSelected];
    button2.tag = 102;
    [button2 addTarget:self action:@selector(button1FirstAction:) forControlEvents:UIControlEventTouchUpInside];
    [yesView addSubview:button2];
    
    button3 = [UIButton buttonWithType:UIButtonTypeCustom];
    button3.frame = CGRectMake(button2.frame.origin.x+button2.frame.size.width, 0, 214/2, 40);
    [button3 setBackgroundImage:[UIImage imageNamed:@"person_page"] forState:UIControlStateNormal];
    [button3 setBackgroundImage:[UIImage imageNamed:@"person_page_down"] forState:UIControlStateSelected];
    button3.tag = 103;
    [button3 addTarget:self action:@selector(button1FirstAction:) forControlEvents:UIControlEventTouchUpInside];
    [yesView addSubview:button3];
    [self.contentView addSubview:yesView];
    
    noView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,320, 40)];
    
    button4 = [UIButton buttonWithType:UIButtonTypeCustom];
    button4.frame = CGRectMake(0, 0, 160, 40);
    [button4 setBackgroundImage:[UIImage imageNamed:@"art_collection_320"] forState:UIControlStateNormal];
    [button4 setBackgroundImage:[UIImage imageNamed:@"art_collection_320_down"] forState:UIControlStateSelected];
    button4.selected = YES;
    button4.tag = 104;
    [button4 addTarget:self action:@selector(button1SeconAction:) forControlEvents:UIControlEventTouchUpInside];
    [noView addSubview:button4];
    
    button5 = [UIButton buttonWithType:UIButtonTypeCustom];
    button5.frame = CGRectMake(160, 0,160, 40);
    [button5 setBackgroundImage:[UIImage imageNamed:@"attend_artist_320"] forState:UIControlStateNormal];
    [button5 setBackgroundImage:[UIImage imageNamed:@"attend_artist_320_down"] forState:UIControlStateSelected];
    button5.tag = 105;
    [button5 addTarget:self action:@selector(button1SeconAction:) forControlEvents:UIControlEventTouchUpInside];
    [noView addSubview:button5];
    [self.contentView addSubview:noView];
    noView.hidden = YES;
    
    artCount = [[UILabel alloc] initWithFrame:CGRectMake(245, button1.frame.origin.y+button1.frame.size.height, 75, 30)];
    artCount.backgroundColor = [UIColor clearColor];
    artCount.textColor = [UIColor grayColor];
    artCount.font = [UIFont systemFontOfSize:13.0];
    artCount.text = [NSString stringWithFormat:@"%@件作品",@"0"];
    [self.contentView addSubview:artCount];
    
    rightView.image = [UIImage imageNamed:@"nav_setting"];
    [self.navigationBarView addSubview:rightView];
    [self.navigationBarView addSubview:rBtn];
    [XDTools showProgress:self.contentView];
    [self initWaterFlowView];
//    [self getDatas];

//    [self  getMyArtistDatas];
    [self getSureDatas];



}
-(void)aa{
    [XDTools hideProgress:self.contentView];
}
//跳到设置界面
-(void)goToSetting{

    PersonSetViewController *perVC = [[PersonSetViewController alloc] init];
    [self.navigationController pushViewController:perVC animated:YES];
}
-(void)goLaun{
    LoginViewController *logVC = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:logVC animated:YES];
}
-(void)shareClick
{
    DDLOG_CURRENT_METHOD;
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:UMAPPKEY
                                      shareText:SHARETITLE
                                     shareImage:[UIImage imageNamed:@"Icon"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToWechatSession,UMShareToWechatTimeline,nil]
                                       delegate:nil];
}



-(void)initWaterFlowView{
    WaterFLayout* flowLayout = [[WaterFLayout alloc]init];
    flowLayout.minimumColumnSpacing = -12.0;
    self.waterfall = [[WaterF alloc]initWithCollectionViewLayout:flowLayout];
//    self.waterfall.imagesArr = self.images;
    
    self.waterfall.textsArr = self.texts;
    self.waterfall.sectionNum = 2;
    self.waterfall.imagewidth = 130;
    self.waterfall.view.frame = CGRectMake(0, 40+30, 320, self.contentView.frame.size.height-40-64);
    self.waterfall.view.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.waterfall.view];
    
    cheader = [[MJRefreshHeaderView  alloc] init];
    cheader.delegate = self;
    cheader.scrollView= _waterfall.collectionView;
    
    cfooter = [[MJRefreshFooterView alloc] init];
    cfooter.delegate = self;
    cfooter.scrollView = _waterfall.collectionView;
    
    
    _artistArray = [NSMutableArray arrayWithCapacity:4];
    //艺术家列表
    self.artistTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 40+30, 320, self.contentView.frame.size.height-40-64-15) style:UITableViewStylePlain];
    _artistTableView.delegate = self;
    _artistTableView.dataSource = self;
    _artistTableView.hidden = YES;
//    _artistTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.contentView addSubview:_artistTableView];
}

//进入刷新就会调用
-(void)refreshViewBeginRefreshing:(MJRefreshBaseView *)refreshView
{
    NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
    
    if (refreshView == cheader){
        isHeaderRefresh = YES;
    }else{
        isHeaderRefresh =NO;
    }
    [self getSureDatas];
    
    //    [dict setObject:@"一页面" forKey:@"页面"];
    //    [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(getNewData:) userInfo:dict repeats:NO];
}

//-(void)getNewData:(NSTimer *)timer
//{
//    NSString * str = [[timer userInfo] objectForKey:@"页面"];
//
//    [self getDatas];
//}

-(void)refreshViewEndRefreshing:(MJRefreshBaseView *)refreshView
{
    if (refreshView == cfooter){
        
        //这里还要判断一下是不是加载没数据，如果没有数据，就执行下面两行，这样就能解决上拉箭头不下了的bug
        if (!isHaveMoreData){
            CGPoint point = _waterfall.collectionView.contentOffset;
            _waterfall.collectionView.contentOffset = CGPointMake(0, point.y-cfooter.frame.size.height);
            DDLOG(@"point = %f,point = %f",point.x,point.y);
        }
    }else{
        
    }
}


//判断是否是艺术家
-(void)myInfoIsArtist{
    uid = [[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_ID];
    if ([XDTools NetworkReachable]){
        NSString *body = [NSString stringWithFormat:@" <myInforIsArtist xmlns=\"http://tempuri.org/\">"
                          "<uid>%@</uid>"
                          "</myInforIsArtist>",uid];
        
        __weak ASIFormDataRequest *request = [XDTools postRequestWithDict:body API:MYIINFORISARTIST];
        [request setCompletionBlock:^{
            [XDTools hideProgress:self.contentView];
            //[XDTools hideProgress:self.contentView];
            NSString *responseString = [request responseString];
            // NSDictionary *tempDic = [XDTools  JSonFromString:responseString];
            DDLOG(@"responseString:%@", responseString);
            
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            int statusCode = [request responseStatusCode];
            NSString *soapAction = [[request requestHeaders] objectForKey:@"SOAPAction"];
            
            NSArray *arraySOAP =[soapAction componentsSeparatedByString:@"/"];
            int count = [arraySOAP count] - 1;
            NSString *methodName = [arraySOAP objectAtIndex:count];
            
            // Use when fetching text data
            NSString *result = nil;
            if (statusCode == 200) {
                //表示正常请求
                result = [SoapXmlParseHelper SoapMessageResultXml:responseString ServiceMethodName:methodName];
                NSDictionary  *responseDict = [XDTools JSonFromString:result];
                DDLOG(@"respodic = %@",responseDict);
                if ([[responseDict objectForKey:@"code"] intValue]==0){

                    NSString *mess = [responseDict objectForKey:@"success"];
                    if ([mess intValue] == 1) {
                        yesView.hidden = NO;
                        noView.hidden = YES;
                    }else{
                        yesView.hidden = YES;
                        noView.hidden = NO;
                    }
                    
                }else{
                    [XDTools showTips:@"数据获取失败" toView:self.contentView];
                }
            }
        }];
        
        [request setFailedBlock:^{
            [XDTools hideProgress:self.contentView];
        }];
        
        [request startAsynchronous];
        [XDTools showProgress:self.contentView];
    }else{
        [XDTools showTips:brokenNetwork toView:self.contentView];
    }
}
-(void)getSureDatas{
    NSString *uId = [[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_ID];
    if ([XDTools NetworkReachable]){
        isHaveMoreData = YES;
        int oldPage = page;
        if (isHeaderRefresh){
            page = 0;
        }else{
            page++;
        }
        DDLOG(@"getDatas************************page = %d",page);
        NSString * pageStr = [NSString stringWithFormat:@"%d",page];
        NSString *body = [NSString stringWithFormat:@" <GetMyArtistListInforsByuid xmlns=\"http://tempuri.org/\">"
                          "<id>%@</id>"
                          "<pageIndex>%@</pageIndex>"
                          "<limit>%@</limit>"
                          "<type>%@</type>"
                          "</GetMyArtistListInforsByuid>",uId,pageStr,@"10",@"0"];
        
        __weak ASIFormDataRequest *request = [XDTools postRequestWithDict:body API:GETMYARTISTINFORBYID];
        [request setCompletionBlock:^{
            [XDTools hideProgress:self.contentView];
            //[XDTools hideProgress:self.contentView];
            NSString *responseString = [request responseString];
            // NSDictionary *tempDic = [XDTools  JSonFromString:responseString];
            DDLOG(@"responseString:%@", responseString);
            
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            int statusCode = [request responseStatusCode];
            NSString *soapAction = [[request requestHeaders] objectForKey:@"SOAPAction"];
            
            NSArray *arraySOAP =[soapAction componentsSeparatedByString:@"/"];
            int count = [arraySOAP count] - 1;
            NSString *methodName = [arraySOAP objectAtIndex:count];
            
            // Use when fetching text data
            NSString *result = nil;
            if (statusCode == 200) {
                //表示正常请求
                if(page == 0){
                    [dataArrary removeAllObjects];
                }
                result = [SoapXmlParseHelper SoapMessageResultXml:responseString ServiceMethodName:methodName];
                NSDictionary  *responseDict = [XDTools JSonFromString:result];
                DDLOG(@"respodic = %@",responseDict);
                if ([[responseDict objectForKey:@"code"] intValue]==0){
                    NSArray *arr = [responseDict objectForKey:@"workList"];
                    for (int i=0; i<arr.count; i++) {
                        NSDictionary *dic = [arr objectAtIndex:i];
                        WaterFlow *water = [[WaterFlow alloc] initWithDic:dic];
                        [dataArrary addObject:water];
                        
                    }
                    self.waterfall.imagesArr = dataArrary;
                    if (dataArrary.count == 0) {
                        page = oldPage;
                    }
                    d1Count = [responseDict objectForKey:@"totalCount"];
                    if ([d1Count isKindOfClass:[NSNull class]]) {
                        d1Count = @"0";
                    }
                    artCount.text = [NSString stringWithFormat:@"%d%@",[[responseDict objectForKey:@"totalCount"] intValue],danwei];
                    [self.waterfall.collectionView reloadData];
                    
                    [cfooter endRefreshing];
                    [cheader endRefreshing];
                    
                }else{
                    [XDTools showTips:@"数据获取失败" toView:self.contentView];
                }
            }
        }];
        
        [request setFailedBlock:^{
            [XDTools hideProgress:self.contentView];
        }];
        
        [request startAsynchronous];
        [XDTools showProgress:self.contentView];
    }else{
        [XDTools showTips:brokenNetwork toView:self.contentView];
    }
}
-(void)button1FirstAction:(UIButton *)sender{
    if (sender.tag == 101) {
        artCount.hidden = NO;
        self.waterfall.view.hidden = NO;
        _artistTableView.hidden = YES;
        danwei = @"件作品";
        artCount.text = [NSString stringWithFormat:@"%@%@",d1Count,danwei];
    }else{
        if (sender.tag == 103) {
            NSString *uide = [[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_ID];
            DetailforArtistVC *artVC = [[DetailforArtistVC alloc]init];
            artVC.typeStr = @"1";
            artVC.idStr = uide;
            [self.navigationController pushViewController:artVC animated:YES];
        }else{
            self.waterfall.view.hidden = YES;
            _artistTableView.hidden = NO;
            danwei = @"名艺术家";
             artCount.text = [NSString stringWithFormat:@"%@%@",d2Count,danwei];
        }
//        artCount.hidden = YES;
    }
        
    if (sender.tag != 103) {
        for (UIButton *b in yesView.subviews) {
            if (b == sender) {
                b.selected = YES;
            }else{
                b.selected = NO;
            }
        }
    }
    
}
-(void)button1SeconAction:(UIButton *)sender{

    if (sender.tag == 105) {
//        artCount.hidden = YES;

        [self  getMyArtistDatas];

        self.waterfall.view.hidden = YES;
        _artistTableView.hidden = NO;
         danwei = @"名艺术家";
         artCount.text = [NSString stringWithFormat:@"%@%@",d2Count,danwei];
    }else{
        artCount.hidden = NO;
        self.waterfall.view.hidden = NO;
        _artistTableView.hidden = YES;
         danwei = @"件作品";
         artCount.text = [NSString stringWithFormat:@"%@%@",d1Count,danwei];
    }
    for (UIButton *b in noView.subviews) {
        if (b == sender) {
            b.selected = YES;
        }else{
            b.selected = NO;
        }
    }
}
-(void)getMyArtistDatas{
    NSString *uId = [[NSUserDefaults standardUserDefaults] objectForKey:kMY_USER_ID];
    if ([XDTools NetworkReachable]){
//        isHaveMoreData = YES;
//        int oldPage = page;
//        if (isHeaderRefresh){
//            page = 0;
//        }else{
//            page++;
//        }
        DDLOG(@"getDatas************************page = %d",page);
//        NSString * pageStr = [NSString stringWithFormat:@"%d",page];
        NSString *body = [NSString stringWithFormat:@" <GetMyArtistListInforsByuid xmlns=\"http://tempuri.org/\">"
                          "<id>%@</id>"
                          "<type>%@</type>"
                          "</GetMyArtistListInforsByuid>",uId,@"1"];
        
        __weak ASIFormDataRequest *request = [XDTools postRequestWithDict:body API:GETMYARTISTINFORBYID];
        [request setCompletionBlock:^{
            [XDTools hideProgress:self.contentView];
            //[XDTools hideProgress:self.contentView];
            NSString *responseString = [request responseString];
            // NSDictionary *tempDic = [XDTools  JSonFromString:responseString];
            DDLOG(@"responseString:%@", responseString);
            
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            int statusCode = [request responseStatusCode];
            NSString *soapAction = [[request requestHeaders] objectForKey:@"SOAPAction"];
            
            NSArray *arraySOAP =[soapAction componentsSeparatedByString:@"/"];
            int count = [arraySOAP count] - 1;
            NSString *methodName = [arraySOAP objectAtIndex:count];
            
            // Use when fetching text data
            NSString *result = nil;
            if (statusCode == 200) {
                //表示正常请求
//                if(page == 0){
//                    [dataArrary removeAllObjects];
//                }
                result = [SoapXmlParseHelper SoapMessageResultXml:responseString ServiceMethodName:methodName];
                NSDictionary  *responseDict = [XDTools JSonFromString:result];
                DDLOG(@"respodic = %@",responseDict);
                if ([[responseDict objectForKey:@"code"] intValue]==0){

                    if (dataArrary.count == 0) {
//                        page = oldPage;
                    }
                    [_artistArray removeAllObjects];

                    for (NSDictionary * dic in [responseDict objectForKey:@"artists"]){
                        ArtistItem * item = [[ArtistItem alloc] init];
                        item.artistId = [NSString stringWithFormat:@"%@",[dic objectForKey:@"artistId"]];
                        item.artistName = [NSString stringWithFormat:@"%@",[dic objectForKey:@"artistName"]];
                        
                        item.artistOpenTime = [NSString stringWithFormat:@"%@",[dic objectForKey:@"artistOpenTime"]];
                        item.artistPortal = [NSString stringWithFormat:@"%@",[dic objectForKey:@"artistPortal"]];
                        item.artistWorkCount = [NSString stringWithFormat:@"%@",[dic objectForKey:@"artistWorkCount"]];
                        [_artistArray addObject:item];
                        d2Count = [NSString stringWithFormat:@"%@",[responseDict objectForKey:@"totalCount"]];
                        if ([d2Count isKindOfClass:[NSNull class]]||[d2Count length] == 0) {
                            d2Count = @"0";
                        }
                    artCount.text = [NSString stringWithFormat:@"%d%@",[[responseDict objectForKey:@"totalCount"] intValue],danwei];
                    [_artistTableView reloadData];
                    }
                    
                }else{
                    [XDTools showTips:@"数据获取失败" toView:self.contentView];
                }
            }
        }];
        
        [request setFailedBlock:^{
            [XDTools hideProgress:self.contentView];
        }];
        
        [request startAsynchronous];
//        [XDTools showProgress:self.contentView];
    }else{
        [XDTools showTips:brokenNetwork toView:self.contentView];
    }
}
#pragma mark  ========================UITableView delegate==========================
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 101/2.0f;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return [_artistArray count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString * cellName = @"cell";
    ArtistCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
    if (cell == nil){
        cell = [[ArtistCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
    }

        if ([_artistArray count]==0){
            return cell;
        }
        ArtistItem * item = [_artistArray objectAtIndex:indexPath.row];
        NSString * iamgeUrl = [NSString stringWithFormat:@"%@%@",ImageMainUrl,item.artistPortal];
        NSString * urlString=[iamgeUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [cell.headImageView setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"11"]];
        //        DDLOG(@"urlString = %@",urlString);
        //        cell.headImageView.image = [UIImage imageNamed:@"66"];
        cell.nameLabel.text = item.artistName;
        if ([item.artistWorkCount intValue]>0){
            cell.numbersLabel.text = [NSString stringWithFormat:@"(%@件作品)",item.artistWorkCount];
        }else{
            cell.numbersLabel.text = nil;
        }
        cell.browseLabel.text = item.artistOpenTime;
        CGRect rect = [XDTools xyAutoSizeOfWidget:cell.nameLabel andSize:CGSizeMake(100, 1000) andtextFont:15];
        cell.nameLabel.frame = CGRectMake(129/2.0f, 37/2.0f, rect.size.width, rect.size.height);
        cell.numbersLabel.frame =CGRectMake(width_x(cell.nameLabel)+23/2.0f, 40/2.0f, 130, 12.5);
        
        CGRect rect2 = [XDTools xyAutoSizeOfWidget:cell.browseLabel andSize:CGSizeMake(100, 1000) andtextFont:12];
        cell.browseLabel.frame = CGRectMake(UI_SCREEN_WIDTH-rect2.size.width-15, rect2.origin.y, rect2.size.width,101/2.0f);
        cell.rightImageView.frame = CGRectMake(cell.browseLabel.frame.origin.x-6-12,42/2.0f, 24/2, 16/2);
        
        return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    

    DetailforArtistVC * dvc = [[DetailforArtistVC alloc] init];

    dvc.typeStr = @"1";
    ArtistItem * item = [_artistArray objectAtIndex:indexPath.row];
    dvc.idStr = item.artistId;
    [self.navigationController pushViewController:dvc animated:YES];
    
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
